package org.xfy.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xfy.base.util.AjaxResult;
import org.xfy.sys.domain.dto.EmailUserRegisterDto;
import org.xfy.sys.domain.dto.PhoneUserRegisterDto;
import org.xfy.sys.service.IRegisterService;

import javax.validation.Valid;

@RestController
@RequestMapping("/register")
public class RegisterController {
    @Autowired
    private IRegisterService registerService;

    /**
     * 用户手机注册
     * @return
     */
    @PostMapping
    public AjaxResult UserRegister(@Valid @RequestBody PhoneUserRegisterDto registerDto){
        return registerService.UserRegister(registerDto);
    }

    /**
     * 邮箱注册
     * @param registerDto
     * @return
     */
    @PostMapping("/email")
    public AjaxResult EmailRegister(@Valid @RequestBody EmailUserRegisterDto registerDto){
        return registerService.EmailRegister(registerDto);
    }

    /**
     * 邮箱注册激活
     * @param email
     * @return
     */
    @GetMapping("/activation/{email}")
    public AjaxResult activation(@PathVariable("email") String email){
        return registerService.activation(email);
    }
}
